]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
swipeTracker: Simplify finding previous point
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 20 Nov 2025 13:34:21 +0000 (14:34 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 24 Nov 2025 13:42:59 +0000 (14:42 +0100)
We have findLastIndex() nowadays to search an array in reverse
direction.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3967>
(cherry picked from commit 8e29babca8adc677fcd5bc8457f497dd849ae884)

js/ui/swipeTracker.js

index 82edef29eaa83e9ef7e7c7707765eefcdae4de59..18f6657db18b39d56488b5bab97e3e51e6b9d51d 100644 (file)
@@ -523,8 +523,7 @@ export const SwipeTracker = GObject.registerClass({
     }
 
     _findPreviousPoint(pos) {
-        const reversedIndex = this._snapPoints.slice().reverse().findIndex(p => p <= pos);
-        return this._snapPoints.length - 1 - reversedIndex;
+        return this._snapPoints.findLastIndex(p => p <= pos);
     }
 
     _findPointForProjection(pos, velocity) {